import Reflux from "reflux"
import BaseAction, {addDefaultListerns} from "@/base/BaseAction";
import GUtils from "@/utils/ajax";

const prefix ="/shop/shopStation/";
const api = {
    search: prefix+"search",
    create: prefix+"create",
    edit: prefix+"edit",
    detail:  prefix+"detail",
    enabled:  prefix+"enabled",
    getShopUnassociatedDeviceList:  prefix+"getShopUnassociatedDeviceList",
};

const createAction = () => {
    const Action = Reflux.createActions({
        ...BaseAction,
        getShopUnassociatedDeviceList:{asyncResult:true},

    });

    addDefaultListerns(Action, api);


    Action.getShopUnassociatedDeviceList.listen(function (shopId, callback) {
        GUtils.Ajax.post(api.getShopUnassociatedDeviceList, {shopId}).then(this.completed.bind(this, callback), this.failed);
    });

    return Action;
};

export {api, createAction}